package tech.aistar.day07;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2022/7/26 3:22 下午
 */
public class StringBuilderDemo {
    public static void main(String[] args) {
        //默认的容量是16 + 3
        StringBuilder x = new StringBuilder("abc");
        x.append("1234567890123456711111111111111111111");
        x.append("ss");
        System.out.println(x.length());//6
        System.out.println(x.capacity());//容量19

        //和String一样不写
        StringBuilder y = new StringBuilder("python");
        y.deleteCharAt(1);//java.lang.StringIndexOutOfBoundsException
        System.out.println(y);//pthon

        y.delete(1,3);//[1,3)
        System.out.println(y);//pon

        System.out.println(y.reverse());//nop
    }
}
